import base64
import time

import requests

target_url = "http://httpbin.org/ip"
proxy_host = 'http-dynamic.xiaoxiangdaili.com'
proxy_port = 10030

# # 应用账号（请替换为真实账号）
app_key = 'app_key'
# # 应用密码（请替换为真实密码）
app_secret = 'app_secret'

authKey = app_key + ':' + app_secret;
authKeyBase64 =  str(base64.b64encode(authKey.encode('utf-8')), "utf-8")
headers = {
    'Proxy-Authorization': 'Basic ' + authKeyBase64
}

proxyMeta = "http://@%(host)s:%(port)s" % {
    "host": proxy_host,
    "port": proxy_port,
    # "user": app_key,
    # "pass": app_secret,
}
proxies = {
    'http': proxyMeta,
    'https': proxyMeta,
}
try:
    for i in range(10):
        resp = requests.get(url=target_url, headers=headers, proxies=proxies, verify=False)
        print(resp.text)
        time.sleep(1)
except Exception as e:
   print(e)
